package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.service.SaveLineService;
@Controller
@Scope(value="prototype")
public class SaveLine implements ServletResponseAware{
	private String lname;
	private String qd;
	private String zd;
	private String way;
	private HttpServletResponse resp;
	
	public String getLname() {
		return lname;
	}
	public void setLname(String lname) {
		this.lname = lname;
	}
	public String getQd() {
		return qd;
	}
	public void setQd(String qd) {
		this.qd = qd;
	}
	public String getZd() {
		return zd;
	}
	public void setZd(String zd) {
		this.zd = zd;
	}
	public String getWay() {
		return way;
	}
	public void setWay(String way) {
		this.way = way;
	}
	@Resource
	private SaveLineService saveline;
	
	public void saveline(){
		if(way.length()==0){
			way=qd+"—>"+zd;
		}
	saveline.saveline(lname, qd, zd, way);
		PrintWriter pw;
		try {
			pw = resp.getWriter();
			pw.write("1");
			pw.flush();
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void setServletResponse(HttpServletResponse resp) {
		this.resp=resp;
	}

}
